<include file="header" />
<body>
<div class="wraper">
    <div class="header flex-between">
        <a href="/base/StoredValue/personalCenter/stored_value_id/{BEESCRM:$stored_value_id}" class="iconfont icon-zuo"></a>
        <div class="title font-16">转账申请</div>
        <a href="/base/StoredValue/moveLog/stored_value_id/{BEESCRM:$stored_value_id}" class="iconfont icon-lishijilu "></a>
    </div>
    <div class="main-card">
        <div class="user flex">
            <div class="logo">
                <img src="/assets/base/StoredValue/images/logo.png" alt="">
            </div>
            <div>
                <p>{BEESCRM:$bind['user_name']}</p>
                <p class="font-12 Student_ID">{BEESCRM:$bind['number']}</p>
            </div>
        </div>
        <div class="text-right font-16">
            余额 <span>{BEESCRM:$bind['balance']}</span> 元
        </div>
        <div class="bg-logo">
            <img src="/assets/base/StoredValue/images/logo.png" alt="">
        </div>
    </div>
    <div class="classify">
        <p class="pay-hint gray">请输入申请转账金额</p>
        <div class="money flex-between">
            <div class="iconfont icon-qian gray2"></div>
            <div class="flex-1">
                <input id="amount" type="text" class="money_input font-16"
                       onkeyup="this.value=this.value.replace(/[^\d.]/g,'')"
                       onafterpaste="this.value=this.value.replace(/[^\d.]/g,'')" >
            </div>
        </div>
    </div>
    <a href="#" class="btn text-center font-16"  id="btn_submit"> 提交</a>
</div>
</body>
<include file="commonJs" />
<script>
    var height=$(window).height();
    $('.wraper').css('minHeight',height);

    $('.js_unbundle').click(function () {
        $('.pop-box').removeClass('hide');
    });
    $('.close').click(function () {
        $('.pop-box').addClass('hide');
    });

    $('#btn_submit').click(function () {
        var amount = $("#amount").val();
        if(amount.length < 1){
            fm.alert("请填写申请转账金额");
            return false;
        }
        var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
        if(!reg.test(amount)){
            fm.alert("金额格式错误");
            return false;
        }
        $('#btn_submit').prop("disabled",true);
        var stored_value_id = "{BEESCRM:$stored_value_id}";
        $.ajax({
            url:"/base/StoredValue/doMoveApply/stored_value_id/" + stored_value_id,
            type:"post",
            dataType:"json",
            data:{amount:amount},
            success:function (res) {
                if(res.status == "S"){
                    fm.alert(res.message,"",2,"");
                    window.sessionStorage.setItem("local_url","/base/StoredValue/moveLog/stored_value_id/"+ stored_value_id);
                    setTimeout(redirect, 2000);
                } else {
                    fm.alert(res.message);
                    $('#btn_submit').prop("disabled",false);
                    return false;
                }
            }
        })
    });
    function redirect() {
        window.location.href = window.sessionStorage.getItem("local_url");
        window.sessionStorage.setItem("local_url",null);
    }
</script>
</html>